# -*- coding: UTF-8 -*-
"""
@author: tgy
@file: 1.4 查找最大或最小的 N 个元素.py
@time: 2021/01/13


"""
import heapq


def test01():
    ...
    nums = [1, 3, 2, 4, 5, 0, 7]

    heapq.merge()
    print(max(nums))
    print(heapq.nlargest(3, nums))
    print(heapq.nsmallest(3, nums))
    # heapq.


def test02():
    ...
    nums = [1, 3, 2, 4, 5, 0, 7]
    # heapq.heappush(nums,6)
    # print(heapq.heappop(nums))
    heapq.heapify(nums)
    print(nums)
    print(heapq.heappop(nums))
    print(heapq.heappop(nums))
    print(heapq.heappop(nums))
    print(heapq.heappop(nums))
    heapq.heappush(nums,6)
    print(heapq.heappop(nums))
    print(heapq.heappop(nums))
    print(heapq.heappop(nums))


if __name__ == '__main__':
    pass
    test02()
